package com.example.testproj.aidl;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class MyAidlTestService extends Service {
    private static final String TAG = "aidl";
    private List<Book> books = new ArrayList<>();

    public MyAidlTestService() {
        Log.d(TAG, "MyAidlTestService: ");
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
//        throw new UnsupportedOperationException("Not yet implemented");
        return stub;
    }

    MyAidlTestStub stub = new MyAidlTestStub() {
        @Override
        public void addBook(Book book) {
            Log.d(TAG, "addBook: 我收到消息了");
            books.add(book);
        }

        @Override
        public List<Book> getBookList() {
            Log.d(TAG, "getBookList: 我收到消息了");
            return books;
        }
    };
}
